<template>
  <div>
    <el-card class="one">
      <span class="left">
        <el-button size="mini"
          >系统首页<i class="el-icon-close el-icon--right"></i
        ></el-button>
        <el-button size="mini" type="primary"
          >用户消息管理<i class="el-icon-close el-icon--right"></i
        ></el-button>
      </span>
      <el-dropdown class="Drop-down-menu">
        <el-button size="mini" type="primary"
          >标签选项<i class="el-icon-arrow-down el-icon--right"></i
        ></el-button>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>关闭其他</el-dropdown-item>
          <el-dropdown-item>关闭所有</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </el-card>
    <el-card class="tow">
      <div>
        <el-form :inline="true" :model="formInline">
          <el-form-item>
            <el-button size="medium" type="primary" class="btn"
              >添加消息
            </el-button></el-form-item
          >

          <el-form-item>
            <el-select
              v-model="formInline.region"
              placeholder="消息类型"
              size="medium"
              style="width: 150px"
            >
              <el-option label="求职" value="求职"></el-option>
              <el-option label="公告" value="公告"></el-option>
              <el-option label="平台" value="平台"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-input
              v-model="formInline.name"
              placeholder="标题"
              size="medium"
              style="width: 300px"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button size="medium" type="primary" class="btn">搜索</el-button>
          </el-form-item>
        </el-form>
      </div>
      <el-table
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange"
        border
      >
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column label="类型" width="200" prop="name">
        </el-table-column>
        <el-table-column label="标题" width="250" prop="title">
        </el-table-column>
        <el-table-column label="简介" width="200" prop="Introduction">
        </el-table-column>
        <el-table-column label="创作时间" width="250" prop="Timestamp">
        </el-table-column>
        <el-table-column label="操作" width="220" prop="name">
          <template slot-scope="scope">
            <el-button
              size="medium"
              type="danger"
              class="btn"
              @click="btnn(scope.$index, scope.row)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage4"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="10"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        class="Pagination"
      >
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "new",
  data() {
    return {
      total: 100,
      currentPage4: 1,
      time: "",

      formInline: {
        region: "",
        name: "",
      },
      tableData: [
        {
          id: 1,
          name: "招聘",
          title: "您有新的招聘信息",
          Introduction:
            "办公室文文员:薪资:3000—5000元,开展专科本科学历提升咨询，开展代招代聘服务。根据公司提供资源介绍。维护客户信息及跟踪。",
          Timestamp: "",
        },
        {
          id: 2,
          name: "求职",
          title: "您有新的求职信息",
          Introduction: "曾凡界:新求职工工作年年龄:联系电话13281098052",
          Timestamp: "",
        },
        {
          id: 3,
          name: "招聘",
          title: "您有新的招聘信息",
          Introduction:
            "办公室文文员:薪资:3000—5000元,开展专科本科学历提升咨询，开展代招代聘服务。根据公司提供资源介绍。维护客户信息及跟踪。",
          Timestamp: "",
        },
        {
          id: 4,
          name: "求职",
          title: "您有新的求职信息",
          Introduction: "曾凡界:新求职工工作年年龄:联系电话13281098052",
          Timestamp: "",
        },
      ],
    };
  },
  mounted() {
    this.getTime(new Date());
  },
  created() {},

  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    handleSelectionChange(val) {
      console.log(val);
    },
    getTime(date) {
      var y = date.getFullYear();

      var m = date.getMonth() + 1;

      m = m < 10 ? "0" + m : m;

      var d = date.getDate();

      d = d < 10 ? "0" + d : d;
      var h = date.getHours();

      h = h < 10 ? "0" + h : h;

      var minute = date.getMinutes();

      minute = minute < 10 ? "0" + minute : minute;

      var second = date.getSeconds();

      second = second < 10 ? "0" + second : second;
      // console.log(this);
      // console.log(this.tableData);
      // return y + '-' + m + '-' + d;
      this.tableData.forEach((item) => {
        // console.log(item.Timestamp);
        item.Timestamp =
          y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
      });
      // for (item of this.tableData) {
      //   console.log(item);
      // }
      // for (let i = 0; i < this.tableData.length; i++) {
      //   console.log(this.tableData[i].Timestamp);
      //   this.tableData[i].Timestamp =
      //     y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
      // }

      // y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
      console.log(
        y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second
      );
    },
    btnn(index, row) {
      // this.$message.error("没做好");
      // console.log(index, row);

      // this.$message.error("删除成功");
      this.$confirm("此操作将永久删除该数据吗？, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.tableData.splice(index, 1);
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },
};
</script>

<style scoped>
.one >>> .el-card__body {
  padding: 3px;
  display: flex;
  justify-content: space-between;
}
.left {
  margin-left: 15px;
}
.Drop-down-menu {
  margin-right: 30px;
}
.tow {
  margin: 25px;
}
.btn {
  border-radius: 8px;
}
.Pagination {
  margin-left: 450px;
  margin-top: 20px;
}
</style>